/*
 * TestMarker.java
 *
 * Created on 30. maj 2007, 01:38
 */

package krut.KRUT_GUI;

/**
 *
 * @author  Jonas
 */
/** GUI for testing the ScreenMarkerLine class */
public class TestMarker extends javax.swing.JFrame {
    
    krut.KRUT_GUI.ScreenMarkerLine myLine;
    
    /** Creates new form TestMarker */
    public TestMarker() {
        initComponents();
        initSML();
        setLocation(myLine.getBounds().x, myLine.getBounds().y - 100);
    }
    
    /** Init the ScreenMarkerLine. */
    private void initSML() {
        myLine = new ScreenMarkerLine(new java.awt.Rectangle(100, 100, 100, 10),
                                        krut.KRUT_GUI.ScreenMarkerLine.HORIZONTAL,
                                        10, 5);
        /** Important, before create line !! */
        myLine.updateLineGraphics();
        myLine.createLine();
    }
    
    private void moved() {
        if (myLine.moveLine(getLocationOnScreen().x,
                        getLocationOnScreen().y + 100) == -1)
            System.out.println("error moving");
    }
    
    private void resized() {
        java.awt.Rectangle bounds = new java.awt.Rectangle(getBounds());
        java.awt.Insets insets = getInsets();
        bounds.x += insets.left;
        bounds.y += insets.top;
        bounds.width -= (insets.left + insets.right);
        bounds.height -= (insets.top + insets.bottom);
//        myLine.setBounds(bounds);
        myLine.updateLineGraphics();
        repaint();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentHidden(java.awt.event.ComponentEvent evt) {
                formComponentHidden(evt);
            }
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                formComponentMoved(evt);
            }
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        pack();
    }
    // </editor-fold>//GEN-END:initComponents

    private void formComponentHidden(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentHidden
// TODO add your handling code here:
    }//GEN-LAST:event_formComponentHidden

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
// TODO add your handling code here:
 //       resized();
    }//GEN-LAST:event_formComponentResized

    private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved
// TODO add your handling code here:
       moved();
    }//GEN-LAST:event_formComponentMoved
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TestMarker().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
